﻿Public Class Main
    Dim template() As String
    Dim fontSize() As Single = {10, 12, 14, 16}
    Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            template = IO.File.ReadAllLines(IO.Path.Combine(My.Application.Info.DirectoryPath, "template.txt"))
            If template Is Nothing OrElse template.Length = 0 Then
                MsgBox("Could not load template styles.")
                End
            End If

            cmbFontTemplates.DataSource = template
        Catch ex As Exception
            ShowError("Error occurred wile loading template styles.", ex)
        End Try

        cmbFontSize.DataSource = fontSize
    End Sub

    Private Sub cmbFontTemplates_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbFontTemplates.SelectedIndexChanged
        txtInput.TempelateString = cmbFontTemplates.SelectedValue
    End Sub

    Public Sub ShowError(ByVal Message As String, ByVal ex As Exception)
        MsgBox(String.Format("{1}{0}Type:{2}{0}Message:{3}", vbCrLf, Message, ex.GetType.ToString, ex.Message), MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, My.Application.Info.Title)
    End Sub

    Private Sub cmbFontSize_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbFontSize.SelectedIndexChanged
        Me.Font = New Font("Tahoma", CSng(cmbFontSize.SelectedValue), GraphicsUnit.Point)
    End Sub

    Private Sub chkCopyOnType_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCopyOnType.CheckedChanged
        txtInput.CopyToClipboard = chkCopyOnType.Checked
    End Sub
End Class